package net.csdn.business.common.feign.mirror;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.csdn.business.common.constant.ServiceNameConstants;
import net.csdn.business.common.domain.mirror.*;
import net.csdn.business.common.domain.query.mirror.MirrorConfigQuery;
import net.csdn.business.common.domain.query.mirror.MirrorPageQuery;
import net.csdn.business.common.domain.query.mirror.TokenConfigQuery;
import net.csdn.business.common.domain.request.mirror.*;
import net.csdn.business.common.domain.vo.mirror.MirrorConfigVO;
import net.csdn.business.common.domain.vo.mirror.MirrorNameSpaceVO;
import net.csdn.business.common.domain.vo.mirror.MirrorProjectPageVO;
import net.csdn.business.common.domain.vo.mirror.ProjectMirrorDataVO;
import net.csdn.business.common.feign.mirror.config.MirrorFeignConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author likun
 * @date 2023/2/3 10:53
 */
@FeignClient(value = ServiceNameConstants.ATOMGIT_MIRROR_SERVICE, contextId = ServiceNameConstants.ATOMGIT_MIRROR_PROJECT_CONTEXT_ID,configuration = MirrorFeignConfiguration.class)
public interface ProjectMirrorFeignClient {
    @PostMapping(value = "/api/v1/mirror/project/uploadData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    List<MirrorUploadDto> importData(@RequestPart("file") MultipartFile file);

    @PostMapping("/api/v1/mirror/project/addData")
    void addData(@RequestBody AddMirrorImportDataDTO dto);

    @PostMapping("/api/v1/mirror/project/addBlack")
    void addBlack(@RequestBody AddMirrorBlackDto addMirrorBlackDto);

    @DeleteMapping("/api/v1/mirror/project/delBlack")
    void delBlack(@RequestBody AddMirrorBlackDto addMirrorBlackDto);

    @GetMapping("/api/v1/mirror/project/getImportSize")
    long importSize();

    @PutMapping("/api/v1/mirror/project/syncStatus")
    public Integer changeMirrorSyncStatus(@RequestBody MirrorSyncStatusDTO params) throws Exception;

    @DeleteMapping("/api/v1/mirror/project")
    public Integer deleteMirror(@RequestBody MirrorDelDTO params)  throws Exception;

    @PostMapping("/api/v1/mirror/project/retry")
    public void retry(@RequestBody MirrorRetyDTO params) throws Exception;

    @PostMapping("/api/v1/mirror/project/exec")
    void exec(@RequestBody AddMirrorImportDataDTO dataDto);

    @PostMapping("/api/v1/mirror/project/saveGithubSource")
    void saveGithubSource(@RequestBody GithubSourceDto sourceDto);

    @GetMapping("/api/v1/mirror/project/getGithubSource")
    GithubSourceDto getGithubSource();

    @PostMapping("/api/v1/mirror/project/import")
    MyGithubDto importProject(@RequestBody AddMirrorImportDataDTO dto);


    /**
     * 前台用户获取导入仓库列表
     */
    @GetMapping("/api/v1/mirror/project/user/list")
    public MirrorProjectPageVO getRepoList(@SpringQueryMap MirrorConfigQuery query) throws Exception;


    /**
     * 前台用户获取源在github或者gittee的全部命名空间
     */
    @GetMapping("/api/v1/mirror/project/namespace")
    public List<MirrorNameSpaceVO> getNamespace(@SpringQueryMap MirrorConfigQuery query) throws Exception;


    /**
     * 前台用户获取token信息配置
     */
    @GetMapping("/api/v1/mirror/project/token")
    public MirrorConfigVO getTokenConfig(@SpringQueryMap TokenConfigQuery query);

    /**
     * 前台用户更新镜像仓库配置或token信息
     */
    @PostMapping("/api/v1/mirror/project/token")
    public void updateTokenConfig(@RequestBody TokenConfigDTO params) throws Exception;



    /**
     * 前台用户获取token镜像仓库配置
     */
    @GetMapping("/api/v1/mirror/project/config")
    public MirrorConfigVO getConfig(@Validated @SpringQueryMap MirrorConfigQuery query);


    /**
     * 前台用户更新镜像仓库配置或token信息
     */
    @PostMapping("/api/v1/mirror/project/config")
    public void updateConfig(@Validated @RequestBody MirroConfigDTO params);



    /**
     * @Description: 管理员分页查询镜像仓库列表
     * @Param:
     * @return:
     * @Author: zhangyl
     * @Date: 2024/7/23
     */
    @PostMapping("/api/v1/mirror/project/list")
    public Page<ProjectMirrorDataVO> listPageMirror(@RequestBody MirrorPageQuery query);


    /**
     * 前台用户,重试导入镜像仓库
     */
    @PostMapping("/api/v1/mirror/project/import/retry")
    public void importProjectRetry(@RequestBody ImportRetryDTO params);
}